﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A84类的定义和对象的创建
{
    class Program
    {
    
        static void Main(string[] args)
        {
            Student s1 = new Student();//创建一个学生对象
            s1.name = "张三";
            Student s2 = new Student();//再创建一个学生对象
            s2.name = "李四";
            s1.SayName();
            s2.SayName();

            Rect rect1 = new Rect();
            rect1.l = 2;
            rect1.w = 3;
            float area = rect1.GetArea();//求面积
            Console.WriteLine(area);

            MyClass mc = new MyClass();
        

        }
    }

    class MyClass
    {
        //数据
        public  int x;
        private   int y; //private 只能再本类内部访问
        //行为
        private void Test() 
        {
        
        }
    }

    //定义 学生类
    class Student
    {
        //数据-变量
        public string name;
        public int age;

        //行为-方法
        public void SayName()
        {
            Console.WriteLine("我是:" + name);
        }
    }

    //矩形类
    class Rect
    {
        //数据
        public float l;//长
        public float w;//宽
    
        //行为
        public float GetArea()  //求面积
        {
            return l * w;
        }

        public float GetPerimeter() //求周长
        {
            return (l + w) * 2;
        }
    }

}
